#define _CRT_SECURE_NO_WARNINGS 1
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
#include <stdio.h>
#include <stdlib.h>
int* productExceptSelf(int* nums, int numsSize) {
    int* answer = (int*)malloc(sizeof(int) * numsSize);
    int i = 0;
    for (i = 0; i < numsSize; i++)
    {
        int j = 0;
        int x = 1;
        for (j = 0; j < numsSize; j++)
        {
            if (i != j)
            {
                x *= nums[j];
            }
            answer[i] = x;
        }
    }
    //*returnSize = numsSize;
    return answer;
}
int main()
{
    int nums[4] = {1, 2, 3, 4};
    int* p = productExceptSelf(nums, 4);
    for (int i = 0; i < 4; i++)
    {
        printf("%d ", p[i]);
    }
    return 0;
}








